package com.shuigu.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shuigu.pojo.dto.RoleMenuDto;
import com.shuigu.pojo.dto.RoleMenuParamDto;
import com.shuigu.pojo.dto.UserRoleDto;
import com.shuigu.pojo.dto.UserRoleParamDto;
import com.shuigu.pojo.entity.UmsSysUser;
import com.shuigu.pojo.vo.RoleMenuVO;
import com.shuigu.pojo.vo.UserRoleVO;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface UmsSysUserMapper extends BaseMapper<UmsSysUser> {

    UmsSysUser selectUserByUserName(@Param("account") String account,@Param("accountType")  int accountType);

    List<UserRoleVO> selectUserRole(Page<UserRoleVO> mpPage, @Param("params") UserRoleParamDto userRoleParamDto);

    boolean deleteUserRoleByIds(@Param("ids") List<Long> ids);

    @Insert("insert into ums_sys_user_role (user_id, role_id) values (#{userId},#{roleId})")
    int saveUserRoel(UserRoleDto userRoleDto);

    List<RoleMenuVO> selectRoleMenu(Page<RoleMenuVO> mpPage, @Param("params") RoleMenuParamDto roleMenuParamDto);

    boolean deleteRoleMenuByIds(@Param("ids") List<Long> ids);

    @Insert("insert into ums_role_menu (role_id, menu_id) values (#{roleId},#{menuId})")
    int saveRoleMenu(RoleMenuDto roleMenuDto);

    /**
     * 根据用户名获取用户
     * @param username
     * @return
     */
    @Select("select * from ums_sys_user where username = #{username}")
    UmsSysUser getByUsername(String username);

    /**
     * 新增用户数统计
     * @param map
     * @return
     */
    Integer countByMap(Map map);
}
